# coding=utf-8
from django.shortcuts import redirect
from django.urls import reverse

from oneself.models import User
from django.core.cache import cache
from django.contrib.sessions.models import Session


def the_one(func):
    '''自定义 验唯一证在线 装饰器'''
    def check_login_status(request):
        if request.session.get('qq', None):
            try:
                hert = request.session.get('hert', None)
                data=User.objects.filter(qq=request.session.get('qq',None)).values('business_card').first()
                if str(hert) == str(data['business_card']):
                    return func(request)
                else:
                    return redirect(reverse('home:login'))
            except:
                return redirect(reverse('home:login'))
        else:
            return redirect(reverse('home:login'))
    return check_login_status
# ————————————————
# 版权声明：本文为CSDN博主「qq_42735170」的原创文章，遵循 CC 4.0 BY-SA 版权协议，转载请附上原文出处链接及本声明。
# 原文链接：https://blog.csdn.net/qq_42735170/article/details/82225771